-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: restart the flow for another policy #49687
fix: restart the flow for another policy #49687
Conversation
@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DylanDylann what is your ETA for testing on this pr?
If we rush, I can start now |
We do not rush specifically, just asking 😂 |
|
||
function ReimbursementAccountPage({route, policy}: ReimbursementAccountPageProps) { | ||
const session = useSession(); | ||
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a fallback value as before?
Same to plaidLinkToken, onfidoToken, plaidCurrentEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koko57 Why don't you think we need it? Let's see the our previous implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DylanDylann I don't see anywhere in the app we're using fallback values for the values from useOnyx. And here if we get undefined or null to won't break anything, the conditions will work the same and the TS is not complaining. So I don't see the reason to add these fallbacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but ok, I see that it was implemented in the conflicting file
Co-authored-by: Vit Horacek <[email protected]> Co-authored-by: DylanDylann <[email protected]>
@mountiny @DylanDylann comments addressed. @DylanDylann I had to reverse your suggestion with parentheses, because prettier was failing. It works as it's supposed |
@DylanDylann could you please test other ways that we can get to VBBA that you may know? |
That would be namely:
|
@mountiny yes, thanks! the first one I also tested myself - it's in the video, but I haven't tested the bottom-up flow |
@koko57 Also please resolve conflict |
@DylanDylann conflicts resolved, could you please retest it? |
/** | ||
* Returns true if a VBBA exists in any state other than OPEN or LOCKED | ||
*/ | ||
function hasInProgressVBBA(): boolean { | ||
return !!achData?.bankAccountID && achData?.state !== BankAccount.STATE.OPEN && achData?.state !== BankAccount.STATE.LOCKED; | ||
return !!achData?.state && achData?.state !== BankAccount.STATE.OPEN && achData?.state !== BankAccount.STATE.LOCKED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you remove bankAccountID check here? We need to check bankAccountID condition before display continue setup button (in getShouldShowContinueSetupButtonInitialValue function)
Screen.Recording.2024-10-01.at.14.25.21.mov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DylanDylann I don't remember, but ok reverting it.
} | ||
|
||
useEffect(() => { | ||
if (!isReimbursementAccountLoading) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koko57 Why do you remove this check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we no longer use isReimbursementAccountLoading here. I removed the local state we're just taking the info about the loading from Onyx. We don't need it locally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Night owl 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koko57 I mean should we replace with reimbursementAccount?.isLoading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temporarily different timezone 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koko57 Bump on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but here I'm changing the logic a bit. This runs only when component mounts. As we no longer set the state like this:
const [isReimbursementAccountLoading, setIsReimbursementAccountLoading] = useState(() => {
// By default return true (loading), if there are already loaded data we can skip the loading state
if (hasACHDataBeenLoaded && typeof reimbursementAccount?.isLoading === 'boolean' && !reimbursementAccount?.isLoading) {
return false;
}
return true;
});
we don't need to check if it's true or false and skip the content of the hook. We also don't need to check for reimbursementAccount?.isLoading, we set it true later and we actually want the whole hook to run on mount. We only don't want to fetch the data if it's the same policy as we already have the data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
@mountiny The change seems more complicated than I thought. I need more time to complete the checklist. (maybe done in tomorrow) |
Thanks! |
); | ||
|
||
const setManualStep = () => { | ||
BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL).then(() => { | ||
setShouldShowContinueSetupButton(false); | ||
}); | ||
fetchData(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koko57 same here, Why do you remove this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to fetch the data here. Besides, when I was working on that that call to API seemed not to be sent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koko57 To safe, If we remove this, I think we need to understand why we added it before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flow is quite complicated. So we should be careful about this change to avoid regression. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DylanDylann as we fetchData when the component mounts we don't need to fetch it once again when we choose manual flow. And as I said - when working on it I've never saw this request being sent (not sure why).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DylanDylann yeah it's complicates 😅 I've tried to simplify it as much as possible.
@@ -289,14 +282,13 @@ function ReimbursementAccountPage({route, policy}: ReimbursementAccountPageProps | |||
Navigation.setParams({stepToOpen: getRouteForCurrentStep(currentStep)}); | |||
}, | |||
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | |||
[isOffline, reimbursementAccount, route, hasACHDataBeenLoaded, shouldShowContinueSetupButton], | |||
[isOffline, reimbursementAccount, route, hasACHDataBeenLoaded, shouldShowContinueSetupButton, policyIDParam], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unnecessary. When policyIDParam change this component will be rendered for sure (because policyIDParam change means that the route change). Please correct me if I am wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep and we no longer use it here - removed!
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps | ||
}, []); // The empty dependency array ensures this runs only once after the component mounts. | ||
|
||
useEffect(() => { | ||
if (typeof reimbursementAccount?.isLoading !== 'boolean' || reimbursementAccount.isLoading === prevIsReimbursementAccountLoading) { | ||
return; | ||
} | ||
setIsReimbursementAccountLoading(reimbursementAccount.isLoading); | ||
setHasACHDataBeenLoaded(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koko57 In case of isLoading is updated from false to true, It will be incorrect. Wdyt If we remove this useEffect? As I understand, this useEffect is to update the deprecated state that no longer use
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DylanDylann yep, I think that makes sense. Although I must have had some idea why I changed this, but I don't remember now 😅
I will check and remove this useEffect or refactor it
Thanks for pointing this out!
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-10-03.at.22.58.57.movAndroid: mWeb ChromeScreen.Recording.2024-10-03.at.22.57.25.moviOS: NativeScreen.Recording.2024-10-03.at.22.55.46.moviOS: mWeb SafariScreen.Recording.2024-10-03.at.22.55.12.movMacOS: Chrome / SafariScreen.Recording.2024-10-03.at.22.52.42.movMacOS: DesktopScreen.Recording.2024-10-03.at.22.54.17.mov |
@DylanDylann seems like removing this useEffect doesn't break anything, could you please retest it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! all yours @grgia
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, NAB comments
function getFieldsForStep(step: TBankAccountStep): InputID[] { | ||
switch (step) { | ||
case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT: | ||
return ['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason these aren't also CONST?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure, it was implemented like that before, I've just taken this function out of the component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not a blocker for now, we can add consts in future PRs if we think it would be cleaner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@grgia Is there any blocker here? |
function getFieldsForStep(step: TBankAccountStep): InputID[] { | ||
switch (step) { | ||
case CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT: | ||
return ['routingNumber', 'accountNumber', 'bankName', 'plaidAccountID', 'plaidAccessToken', 'isSavings']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not a blocker for now, we can add consts in future PRs if we think it would be cleaner
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/mountiny in version: 9.0.46-0 🚀
|
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.46-5 🚀
|
Details
Fixed Issues
$ #49447
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2024-09-26.at.19.18.23.mp4
MacOS: Desktop